"""
The versioning module controls the storage of model versions.
"""
from sync.util import load_backend

backend = load_backend('SYNC_BACKEND','hg')

def save(model,pk,data):
    """
    Saves the model instance.
    """
    return backend.save(model,pk,data)

def get(model,pk,version=None):
    """
    Gets the latest version of the specified model instance.
    """
    return backend.get(model,pk,version)

def get_versions(model,pk):
    """
    Gets the available versions of the specified model instance.
    """
    return backend.get_versions(model,pk)

def delete(model,pk):
    """
    Deletes the specified model instance.
    """
    return backend.delete(model,pk)
